using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RpgXna.Model.Menu.MenuBehaviors;

namespace RpgXna.Model.Interfaces.MainMenu
{
    internal class MenuButton
    {
        private readonly IMenuBehavior _action;

        public MenuButton(Texture2D t, float xMod, float y, IMenuBehavior action = null)
        {
            _action = action;
            Texture = t;
            Position = new Vector2(xMod - (float)Texture.Width / 2, y);
            Box = new Rectangle((int)Position.X, (int)Position.Y, Texture.Width, Texture.Height);
        }

        public Texture2D Texture { get; private set; }

        public Vector2 Position { get; private set; }

        public Rectangle Box { get; private set; }

        public void DoAction()
        {
            if (_action != null)
            {
                _action.Execute();
            }
        }

        public void Draw(SpriteBatch sb)
        {
            sb.Draw(Texture, Position, Color.White);
        }
    }
}